home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / ahidev.lha / AHI / Developer / docs / ahi.doc < prev    next >
Encoding:
Text File  |  1997-08-19  |  63.3 KB  |  2,006 lines

  1. TABLE OF CONTENTS
  2. 0001 ahi.device/--background--
  3. 0002 ahi.device/AHI_AllocAudioA
  4. 0003 ahi.device/AHI_AllocAudioRequestA
  5. 0004 ahi.device/AHI_AudioRequestA
  6. 0005 ahi.device/AHI_BestAudioIDA
  7. 0006 ahi.device/AHI_ControlAudioA
  8. 0007 ahi.device/AHI_FreeAudio
  9. 0008 ahi.device/AHI_FreeAudioRequest
  10. 0009 ahi.device/AHI_GetAudioAttrsA
  11. 0010 ahi.device/AHI_LoadSound
  12. 0011 ahi.device/AHI_NextAudioID
  13. 0012 ahi.device/AHI_PlayA
  14. 0013 ahi.device/AHI_SampleFrameSize
  15. 0014 ahi.device/AHI_SetEffect
  16. 0015 ahi.device/AHI_SetFreq
  17. 0016 ahi.device/AHI_SetSound
  18. 0017 ahi.device/AHI_SetVol
  19. 0018 ahi.device/AHI_UnloadSound
  20. 0019 ahi.device/CMD_FLUSH
  21. 0020 ahi.device/CMD_READ
  22. 0021 ahi.device/CMD_RESET
  23. 0022 ahi.device/CMD_START
  24. 0023 ahi.device/CMD_STOP
  25. 0024 ahi.device/CMD_WRITE
  26. 0025 ahi.device/CloseDevice
  27. 0026 ahi.device/NSCMD_DEVICEQUERY
  28. 0027 ahi.device/OpenDevice
  29. ahi.device/--background--
  30.  
  31. PURPOSE
  32.  
  33.        The 'ahi.device' was first created because the lack of standards
  34.        when it comes to sound cards on the Amiga. Another reason was to
  35.        make it easier to write multi-channel music programs.
  36.  
  37.        This device is by no means the final and perfect solution. But
  38.        hopefully, it can evolve into something useful until AT brings you
  39.        The Real Thing (TM).
  40.  
  41.  
  42. OVERVIEW
  43.  
  44.        Please see the document "AHI Developer's Guide" for more
  45.        information.
  46.  
  47.  
  48.        * Driver based
  49.  
  50.        Each supported sound card is controlled by a library-based audio
  51.        driver. For a 'dumb' sound card, a new driver should be written in
  52.        a few hours. For a 'smart' sound card, it is possible to utilize an
  53.        on-board DSP, for example, to maximize performance and sound quality.
  54.        For sound cards with own DSP but little or no memory, it is possible
  55.        to use the main CPU to mix channels and do the post-processing
  56.        with the DSP. Drivers are available for most popular sound cards,
  57.        as well as an 8SVX (mono) and AIFF/AIFC (mono & stereo) sample render
  58.        driver.
  59.   
  60.        * Fast, powerful mixing routines (yeah, right... haha)
  61.   
  62.        The device's mixing routines mix 8- or 16-bit signed samples, both
  63.        mono and stereo, located in Fast-RAM and outputs 16-bit mono or stereo
  64.        (with stereo panning if desired) data, using any number of channels
  65.        (as long as 'any' means less than 128...).  Tables can be used speed
  66.        the mixing up (especially when using 8-bit samples).  The samples can
  67.        have any length (including odd) and can have any number of loops.
  68.        There are also so-called HiFi mixing routines that can be used, that
  69.        use linear interpolation and gives 32 bit output.
  70.        
  71.        * Support for non-realtime mixing
  72.   
  73.        By providing a timing feature, it is possible to create high-
  74.        quality output even if the processing power is lacking, by saving
  75.        the output to disk, for example as an IFF AIFF or 8SXV file.
  76.   
  77.        * Audio database
  78.   
  79.        Uses ID codes, much like Screenmode IDs, to select the many
  80.        parameters that can be set. The functions to access the audio
  81.        database are not too different from those in 'graphics.library'.
  82.        The device also features a requester to get an ID code from the
  83.        user.
  84.   
  85.        * Both high- and low-level protocol
  86.   
  87.        By acting both like a device and a library, AHI gives the programmer
  88.        a choice between full control and simplicity. The device API allows
  89.        several programs to use the audio hardware at the same time, and
  90.        the AUDIO: dos-device driver makes playing and recording sound very
  91.        simple for both the programmer and user.
  92.   
  93.        * Future Compatible
  94.   
  95.        When AmigaOS gets device-independent audio worth it's name, it should
  96.        not be too difficult to write a driver for AHI, allowing applications
  97.        using 'ahi.device' to automatically use the new OS interface. At
  98.        least I hope it wont.
  99.  
  100.  
  101.  
  102. ahi.device/AHI_AllocAudioA
  103.  
  104. NAME
  105.        AHI_AllocAudioA -- allocates and initializes the audio hardware
  106.        AHI_AllocAudio -- varargs stub for AHI_AllocAudioA()
  107.  
  108.  
  109. SYNOPSIS
  110.        audioctrl = AHI_AllocAudioA( tags );
  111.        D0                           A1
  112.  
  113.        struct AHIAudioCtrl *AHI_AllocAudioA( struct TagItem * );
  114.  
  115.        audioctrl = AHI_AllocAudio( tag1, ... );
  116.  
  117.        struct AHIAudioCtrl *AHI_AllocAudio( Tag, ... );
  118.  
  119.  
  120. FUNCTION
  121.        Allocates and initializes the audio hardware, selects the best
  122.        mixing routine (if necessary) according to the supplied tags.
  123.        To start playing you first need to call AHI_ControlAudioA().
  124.  
  125.  
  126. INPUTS
  127.        tags - A pointer to a tag list.
  128.  
  129.  
  130. TAGS
  131.  
  132.        AHIA_AudioID (ULONG) - The audio mode to use (AHI_DEFAULT_ID is the
  133.            user's default mode. It's a good value to use the first time she
  134.            starts your application.
  135.  
  136.        AHIA_MixFreq (ULONG) - Desired mixing frequency. The actual
  137.            mixing rate may or may not be exactly what you asked for.
  138.            AHI_DEFAULT_FREQ is the user's prefered frequency.
  139.  
  140.        AHIA_Channels (UWORD) - Number of channel to use. The actual
  141.            number of channels used will be equal or grater than the
  142.            requested. If too many channels were requested, this function
  143.            will fail. This tag must be supplied.
  144.  
  145.        AHIA_Sounds (UWORD) - Number of sounds to use. This tag must be
  146.            supplied.
  147.  
  148.        AHIA_SoundFunc (struct Hook *) - A function to call each time
  149.            when a sound has been started. The function receives the
  150.            following parameters:
  151.                A0 - (struct Hook *)
  152.                A2 - (struct AHIAudioCtrl *)
  153.                A1 - (struct AHISoundMessage *)
  154.            The hook may be called from an interrupt, so normal interrupt
  155.            restrictions apply.
  156.            The called function should follow normal register conventions,
  157.            which means that d2-d7 and a2-a6 must be preserved.
  158.  
  159.        AHIA_PlayerFunc (struct Hook *) - A function to be called at regular
  160.            intervals. By using this hook there is no need for music players
  161.            to use other timing, such as VBLANK or CIA timers. But the real
  162.            reason it's present is that it makes it possible to do non-
  163.            realtime mixing to disk.
  164.            Using this interrupt source is currently the only supported way
  165.            to ensure that no mixing occurs between calls to AHI_SetVol(),
  166.            AHI_SetFreq() or AHI_SetSound().
  167.            If the sound playback is done without mixing, 'realtime.library'
  168.            is used to provide timing. The function receives the following
  169.            parameters:
  170.                A0 - (struct Hook *)
  171.                A2 - (struct AHIAudioCtrl *)
  172.                A1 - Undefined.
  173.            Do not assume A1 contains any particular value!
  174.            The hook may be called from an interrupt, so normal interrupt
  175.            restrictions apply.
  176.            The called function should follow normal register conventions,
  177.            which means that d2-d7 and a2-a6 must be preserved.
  178.  
  179.        AHIA_PlayerFreq (Fixed) - If non-zero, enables timing and specifies
  180.            how many times per second PlayerFunc will be called. This must
  181.            be specified if AHIA_PlayerFunc is! Do not use any extreme
  182.            frequencies. The result of MixFreq/PlayerFreq must fit an UWORD,
  183.            ie it must be less or equal to 65535. It is also suggested that
  184.            you keep the result over 80. For normal use this should not be a
  185.            problem. Note that the data type is Fixed, not integer. 50 Hz is
  186.            50<<16.
  187.  
  188.        AHIA_MinPlayerFreq (Fixed) - The minimum frequency (AHIA_PlayerFreq)
  189.            you will use. You should always supply this if you are using the
  190.            device's interrupt feature!
  191.  
  192.        AHIA_MaxPlayerFreq (Fixed) - The maximum frequency (AHIA_PlayerFreq)
  193.            you will use. You should always supply this if you are using the
  194.            device's interrupt feature!
  195.  
  196.        AHIA_RecordFunc (struct Hook *) - This function will be called
  197.            regularly when sampling is turned on (see AHI_ControlAudioA())
  198.            with the following parameters:
  199.                A0 - (struct Hook *)
  200.                A2 - (struct AHIAudioCtrl *)
  201.                A1 - (struct AHIRecordMessage *)
  202.            The message (AHIRecordMessage) is filled as follows:
  203.                ahirm_Buffer - Pointer to the samples. The buffer is valid
  204.                    until next time the Hook is called.
  205.                ahirm_Length - Number of sample FRAMES in buffer.
  206.                    To get the size in bytes, multiply by 4 if ahiim_Type is
  207.                    AHIST_S16S.
  208.                ahirm_Type - Always AHIST_S16S at the moment, but you *must*
  209.                    check this, since it may change in the future!
  210.            The hook may be called from an interrupt, so normal interrupt
  211.            restrictions apply. Signal a process if you wish to save the
  212.            buffer to disk. The called function should follow normal register
  213.            conventions, which means that d2-d7 and a2-a6 must be preserved.
  214.        *** NOTE: The function MUST return NULL (in d0). This was previously
  215.            not documented. Now you know.
  216.  
  217.        AHIA_UserData (APTR) - Can be used to initialize the ahiac_UserData
  218.            field.
  219.  
  220.  
  221. RESULT
  222.        A pointer to an AHIAudioCtrl structure or NULL if an error occured.
  223.  
  224.  
  225. EXAMPLE
  226.  
  227.  
  228. NOTES
  229.  
  230.  
  231. BUGS
  232.  
  233.  
  234. SEE ALSO
  235.        AHI_FreeAudio(), AHI_ControlAudioA()
  236.  
  237.  
  238. ahi.device/AHI_AllocAudioRequestA
  239.  
  240. NAME
  241.        AHI_AllocAudioRequestA -- allocate an audio mode requester.
  242.        AHI_AllocAudioRequest -- varargs stub for AHI_AllocAudioRequestA()
  243.  
  244.  
  245. SYNOPSIS
  246.        requester = AHI_AllocAudioRequestA( tags );
  247.        D0                                  A0
  248.  
  249.        struct AHIAudioModeRequester *AHI_AllocAudioRequestA(
  250.            struct TagItem * );
  251.  
  252.        requester = AHI_AllocAudioRequest( tag1, ... );
  253.  
  254.        struct AHIAudioModeRequester *AHI_AllocAudioRequest( Tag, ... );
  255.  
  256.  
  257. FUNCTION
  258.        Allocates an audio mode requester data structure.
  259.  
  260.  
  261. INPUTS
  262.        tags - A pointer to an optional tag list specifying how to initialize
  263.            the data structure returned by this function. See the
  264.            documentation for AHI_AudioRequestA() for an explanation of how
  265.            to use the currently defined tags.
  266.  
  267.  
  268. RESULT
  269.        requester - An initialized requester data structure, or NULL on
  270.            failure. 
  271.  
  272.  
  273. EXAMPLE
  274.  
  275.  
  276. NOTES
  277.        The requester data structure is READ-ONLY and can only be modified
  278.        by using tags!
  279.  
  280.  
  281. BUGS
  282.  
  283.  
  284. SEE ALSO
  285.       AHI_AudioRequestA(), AHI_FreeAudioRequest()
  286.  
  287.  
  288. ahi.device/AHI_AudioRequestA
  289.  
  290. NAME
  291.        AHI_AudioRequestA -- get an audio mode from user using an requester.
  292.        AHI_AudioRequest -- varargs stub for AHI_AudioRequestA()
  293.  
  294.  
  295. SYNOPSIS
  296.        success = AHI_AudioRequestA( requester, tags );
  297.        D0                           A0         A1
  298.  
  299.        BOOL AHI_AudioRequestA( struct AHIAudioModeRequester *,
  300.            struct TagItem * );
  301.  
  302.        result = AHI_AudioRequest( requester, tag1, ... );
  303.  
  304.        BOOL AHI_AudioRequest( struct AHIAudioModeRequester *, Tag, ... );
  305.  
  306.  
  307. FUNCTION
  308.        Prompts the user for an audio mode, based on the modifying tags.
  309.        If the user cancels or the system aborts the request, FALSE is
  310.        returned, otherwise the requester's data structure reflects the
  311.        user input.
  312.  
  313.        Note that tag values stay in effect for each use of the requester
  314.        until they are cleared or modified by passing the same tag with a
  315.        new value.
  316.  
  317.  
  318. INPUTS
  319.        requester - Requester structure allocated with
  320.            AHI_AllocAudioRequestA(). If this parameter is NULL, this
  321.            function will always return FALSE with a dos.library/IoErr()
  322.            result of ERROR_NO_FREE_STORE.
  323.        tags - Pointer to an optional tag list which may be used to control
  324.            features of the requester.
  325.  
  326.  
  327. TAGS
  328.        Tags used for the requester (they look remarkable similar to the
  329.        screen mode requester in ASL, don't they? ;-) )
  330.  
  331.        AHIR_Window (struct Window *) - Parent window of requester. If no
  332.            AHIR_Screen tag is specified, the window structure is used to
  333.            determine on which screen to open the requesting window.
  334.  
  335.        AHIR_PubScreenName (STRPTR) - Name of a public screen to open on.
  336.            This overrides the screen used by AHIR_Window.
  337.  
  338.        AHIR_Screen (struct Screen *) - Screen on which to open the
  339.            requester. This overrides the screen used by AHIR_Window or by
  340.            AHIR_PubScreenName.
  341.  
  342.        AHIR_PrivateIDCMP (BOOL) - When set to TRUE, this tells AHI to
  343.            allocate a new IDCMP port for the requesting window. If not
  344.            specified or set to FALSE, and if AHIR_Window is provided, the
  345.            requesting window will share AHIR_Window's IDCMP port.
  346.  
  347.        AHIR_IntuiMsgFunc (struct Hook *) - A function to call whenever an
  348.            unknown Intuition message arrives at the message port being used
  349.            by the requesting window. The function receives the following
  350.            parameters:
  351.                A0 - (struct Hook *)
  352.                A1 - (struct IntuiMessage *)
  353.                A2 - (struct AHIAudioModeRequester *)
  354.  
  355.        AHIR_SleepWindow (BOOL) - When set to TRUE, this tag will cause the
  356.            window specified by AHIR_Window to be "put to sleep". That is, a
  357.            busy pointer will be displayed in the parent window, and no
  358.            gadget or menu activity will be allowed. This is done by opening
  359.            an invisible Intuition Requester in the parent window.
  360.  
  361.        AHIR_UserData (APTR) - A 32-bit value that is simply copied in the
  362.            ahiam_UserData field of the requester structure.
  363.  
  364.        AHIR_TextAttr (struct TextAttr *) - Font to be used for the
  365.            requesting window's gadgets and menus. If this tag is not
  366.            provided or its value is NULL, the default font of the screen
  367.            on which the requesting window opens will be used. This font
  368.            must already be in memory as AHI calls OpenFont() and not
  369.            OpenDiskFont().
  370.  
  371.        AHIR_Locale (struct Locale *) - Locale to use for the requesting
  372.            window. This determines the language used for the requester's
  373.            gadgets and menus. If this tag is not provided or its value is
  374.            NULL, the system's current default locale will be used.
  375.  
  376.        AHIR_TitleText (STRPTR) - Title to use for the requesting window.
  377.            Default is no title.
  378.  
  379.        AHIR_PositiveText (STRPTR) - Label of the positive gadget in the
  380.            requester. English default is "OK".
  381.  
  382.        AHIR_NegativeText (STRPTR) - Label of the negative gadget in the
  383.            requester. English default is "Cancel".
  384.  
  385.        AHIR_InitialLeftEdge (WORD) - Suggested left edge of requesting
  386.            window.
  387.  
  388.        AHIR_InitialTopEdge (WORD) - Suggested top edge of requesting
  389.            window.
  390.  
  391.        AHIR_InitialWidth (WORD) - Suggested width of requesting window.
  392.  
  393.        AHIR_InitialHeight (WORD) - Suggested height of requesting window.
  394.  
  395.        AHIR_InitialAudioID (ULONG) - Initial setting of the Mode list view
  396.            gadget (ahiam_AudioID). Default is ~0 (AHI_INVALID_ID), which
  397.            means that no mode will be selected.
  398.  
  399.        AHIR_InitialMixFreq (ULONG) - Initial setting of the frequency
  400.            slider. Default is the lowest frequency supported.
  401.  
  402.        AHIR_InitialInfoOpened (BOOL) - Whether to open the property
  403.            information window automatically. Default is FALSE.
  404.  
  405.        AHIR_InitialInfoLeftEdge (WORD) - Initial left edge of information
  406.            window.
  407.  
  408.        AHIR_InitialInfoTopEdge (WORD) - Initial top edge of information
  409.            window.
  410.  
  411.        AHIR_DoMixFreq (BOOL) - Set this tag to TRUE to cause the requester
  412.            to display the frequency slider gadget. Default is FALSE.
  413.  
  414.        AHIR_DoDefaultMode (BOOL) - Set this tag to TRUE to let the user
  415.            select the mode she has set in the preferences program. If she
  416.            selects this mode,  ahiam_AudioID will be AHI_DEFAULT_ID and
  417.            ahiam_MixFreq will be AHI_DEFAULT_FREQ. Note that if you filter
  418.            the mode list (see below), you must also check the mode (with
  419.            AHI_BestAudioIDA()) before you use it since the user may change 
  420.            the meaning of AHI_DEFAULT_MODE anytime, without your knowledge.
  421.            Default is FALSE. (V4)
  422.  
  423.        AHIR_FilterFunc (struct Hook *) - A function to call for each mode
  424.            encountered. If the function returns TRUE, the mode is included
  425.            in the file list, otherwise it is rejected and not displayed. The
  426.            function receives the following parameters:
  427.                A0 - (struct Hook *)
  428.                A1 - (ULONG) mode id
  429.                A2 - (struct AHIAudioModeRequester *)
  430.  
  431.        AHIR_FilterTags (struct TagItem *) - A pointer to a tag list used to
  432.            filter modes away, like AHIR_FilterFunc does. The tags are the
  433.            same as AHI_BestAudioIDA() takes as arguments. See that function
  434.            for an explanation of each tag.
  435.  
  436.  
  437. RESULT
  438.        result - FALSE if the user cancelled the requester or if something
  439.            prevented the requester from opening. If TRUE, values in the
  440.            requester structure will be set.
  441.  
  442.            If the return value is FALSE, you can look at the result from the
  443.            dos.library/IoErr() function to determine whether the requester
  444.            was cancelled or simply failed to open. If dos.library/IoErr()
  445.            returns 0, then the requester was cancelled, any other value
  446.            indicates a failure to open. Current possible failure codes are
  447.            ERROR_NO_FREE_STORE which indicates there was not enough memory,
  448.            and ERROR_NO_MORE_ENTRIES which indicates no modes were available
  449.            (usually because the application filter hook filtered them all
  450.            away).
  451.  
  452.  
  453. EXAMPLE
  454.  
  455.  
  456. NOTES
  457.        The requester data structure is READ-ONLY and can only be modified
  458.        by using tags!
  459.  
  460.        The mixing/recording frequencies that are presented to the user
  461.        may not be the only ones a driver supports, but just a selection.
  462.  
  463.  
  464. BUGS
  465.  
  466.  
  467. SEE ALSO
  468.       AHI_AllocAudioRequestA(), AHI_FreeAudioRequest()
  469.  
  470.  
  471. ahi.device/AHI_BestAudioIDA
  472.  
  473. NAME
  474.        AHI_BestAudioIDA -- calculate the best ModeID with given parameters
  475.        AHI_BestAudioID -- varargs stub for AHI_BestAudioIDA()
  476.  
  477.  
  478. SYNOPSIS
  479.        ID = AHI_BestAudioIDA( tags );
  480.        D0                     A1
  481.  
  482.        ULONG AHI_BestAudioIDA( struct TagItem * );
  483.  
  484.        ID = AHI_BestAudioID( tag1, ... );
  485.  
  486.        ULONG AHI_BestAudioID( Tag, ... );
  487.  
  488.  
  489. FUNCTION
  490.        Determines the best AudioID to fit the parameters set in the tag
  491.        list.
  492.  
  493.  
  494. INPUTS
  495.        tags - A pointer to a tag list. Only the tags present matter.
  496.  
  497.  
  498. TAGS
  499.        Many combinations are probably stupid to ask for, like not supporting
  500.        panning or recording.
  501.  
  502.        AHIDB_AudioID (ULONG) - The mode must use the same audio hardware
  503.            as this mode does.
  504.  
  505.        AHIDB_Volume (BOOL) - If TRUE: mode must support volume changes.
  506.            If FALSE: mode must not support volume changes.
  507.  
  508.        AHIDB_Stereo (BOOL) - If TRUE: mode must have stereo output.
  509.            If FALSE: mode must not have stereo output (=mono).
  510.  
  511.        AHIDB_Panning (BOOL) - If TRUE: mode must support volume panning.
  512.            If FALSE: mode must not support volume panning. 
  513.  
  514.        AHIDB_HiFi (BOOL) - If TRUE: mode must have HiFi output.
  515.            If FALSE: mode must not have HiFi output.
  516.  
  517.        AHIDB_PingPong (BOOL) - If TRUE: mode must support playing samples
  518.            backwards. If FALSE: mode must not support playing samples
  519.            backwards.
  520.  
  521.        AHIDB_Record (BOOL) - If TRUE: mode must support recording. If FALSE:
  522.            mode must not support recording.
  523.  
  524.        AHIDB_Realtime (BOOL) - If TRUE: mode must be realtime. If FALSE:
  525.            take a wild guess.
  526.  
  527.        AHIDB_FullDuplex (BOOL) - If TRUE: mode must be able to record and
  528.            play at the same time.
  529.  
  530.        AHIDB_Bits (UBYTE) - Mode must have greater or equal number of bits.
  531.  
  532.        AHIDB_MaxChannels (UWORD) - Mode must have greater or equal number
  533.            of channels.
  534.  
  535.        AHIDB_MinMixFreq (ULONG) - Lowest mixing frequency supported must be
  536.            less or equal.
  537.  
  538.        AHIDB_MaxMixFreq (ULONG) - Highest mixing frequency must be greater
  539.            or equal.
  540.  
  541.        AHIB_Dizzy (struct TagItem *) - This tag points to a second tag list.
  542.            After all other tags has been tested, the mode that matches these
  543.            tags best is returned, i.e. the one that has most of the features
  544.            you ask for, and least of the ones you don't want. Without this
  545.            second tag list, this function hardly does what its name
  546.            suggests. (V4)
  547.  
  548.  
  549. RESULT
  550.        ID - The best AudioID to use or AHI_INVALID_ID if none of the modes
  551.            in the audio database could meet the requirements.
  552.  
  553.  
  554. EXAMPLE
  555.  
  556.  
  557. NOTES
  558.  
  559.  
  560. BUGS
  561.  
  562.  
  563. SEE ALSO
  564.       AHI_NextAudioID(), AHI_GetAudioAttrsA()
  565.  
  566.  
  567. ahi.device/AHI_ControlAudioA
  568.  
  569. NAME
  570.        AHI_ControlAudioA -- change audio attributes
  571.        AHI_ControlAudio -- varargs stub for AHI_ControlAudioA()
  572.  
  573.  
  574. SYNOPSIS
  575.        error = AHI_ControlAudioA( audioctrl, tags );
  576.        D0                         A2         A1
  577.  
  578.        ULONG AHI_ControlAudioA( struct AHIAudioCtrl *, struct TagItem * );
  579.  
  580.        error = AHI_ControlAudio( AudioCtrl, tag1, ...);
  581.  
  582.        ULONG AHI_ControlAudio( struct AHIAudioCtrl *, Tag, ... );
  583.  
  584.  
  585. FUNCTION
  586.        This function should be used to change attributes for a given
  587.        AHIAudioCtrl structure. It is also used to start and stop playback,
  588.        and to control special hardware found on some sound cards.
  589.  
  590.  
  591. INPUTS
  592.        audioctrl - A pointer to an AHIAudioCtrl structure.
  593.        tags - A pointer to a tag list.
  594.  
  595.  
  596. TAGS
  597.        AHIC_Play (BOOL) - Starts (TRUE) and stops (FALSE) playback and
  598.            PlayerFunc. NOTE: If the audio hardware cannot play at the same
  599.            time as recording samples, the recording will be stopped.
  600.  
  601.        AHIC_Record (BOOL) - Starts (TRUE) and stops (FALSE) sampling and
  602.            RecordFunc. NOTE: If the audio hardware cannot record at the same
  603.            time as playing samples, the playback will be stopped.
  604.  
  605.        AHIC_MonitorVolume (Fixed) - Sets the input monitor volume, i.e. how
  606.            much of the input signal is mixed with the output signal while
  607.            recording. Use AHI_GetAudioAttrsA() to find the available range.
  608.  
  609.        AHIC_MonitorVolume_Query (Fixed *) - Get the current input monitor
  610.            volume. ti_Data is a pointer to a Fixed variable, where the result
  611.            will be stored.
  612.  
  613.        AHIC_MixFreq_Query (ULONG *) - Get the current mixing frequency.
  614.            ti_Data is a pointer to an ULONG variable, where the result will
  615.            be stored.
  616.  
  617.        AHIC_InputGain (Fixed) - Set the input gain. Use AHI_GetAudioAttrsA()
  618.            to find the available range. (V2)
  619.  
  620.        AHIC_InputGain_Query (Fixed *) - Get current input gain. (V2)
  621.  
  622.        AHIC_OutputVolume (Fixed) - Set the output volume. Use
  623.            AHI_GetAudioAttrsA() to find the available range. (V2)
  624.  
  625.        AHIC_OutputVolume_Query (Fixed *) - Get current output volume. (V2)
  626.  
  627.        AHIC_Input (ULONG) - Select input source. See AHI_GetAudioAttrsA().
  628.            (V2)
  629.  
  630.        AHIC_Input_Query (ULONG *) - Get current input source. (V2)
  631.  
  632.        AHIC_Output (ULONG) - Select destination for output. See
  633.            AHI_GetAudioAttrsA(). (V2)
  634.  
  635.        AHIC_Output_Query (ULONG *) - Get destination for output. (V2)
  636.  
  637.        The following tags are also recognized by AHI_ControlAudioA(). See
  638.        AHI_AllocAudioA() for what they do. They may be used from interrupts.
  639.  
  640.        AHIA_SoundFunc (struct Hook *)
  641.        AHIA_PlayerFunc (struct Hook *)
  642.        AHIA_PlayerFreq (Fixed)
  643.        AHIA_RecordFunc (struct Hook *)
  644.        AHIA_UserData (APTR)
  645.  
  646.        Note that AHIA_PlayerFreq must never be outside the limits specified
  647.        with AHIA_MinPlayerFreq and AHIA_MaxPlayerFreq! Also note that the
  648.        timing feature is designed to be used for music. When you change the
  649.        frequency, be reasonable. Using 50 Hz one moment and 5 the other is
  650.        to ask for trouble.
  651.  
  652.  
  653. RESULT
  654.        An error code, defined in <devices/ahi.h>.
  655.  
  656.  
  657. EXAMPLE
  658.  
  659.  
  660. NOTES
  661.        The AHIC_Play and AHIC_Record tags *must not* be used from
  662.        interrupts.
  663.  
  664.  
  665. BUGS
  666.  
  667.  
  668. SEE ALSO
  669.        AHI_AllocAudioA(), AHI_GetAudioAttrsA(), <devices/ahi.h>
  670.  
  671.  
  672. ahi.device/AHI_FreeAudio
  673.  
  674. NAME
  675.        AHI_FreeAudio -- deallocates the audio hardware
  676.  
  677.  
  678. SYNOPSIS
  679.        AHI_FreeAudio( audioctrl );
  680.                       A2
  681.  
  682.        void AHI_FreeAudio( struct AHIAudioCtrl * );
  683.  
  684.  
  685. FUNCTION
  686.        Deallocates the AHIAudioCtrl structure and any other resources
  687.        allocated by AHI_AllocAudioA(). After this call it must not be used
  688.        by any other functions anymore. AHI_UnloadSound() is automatically
  689.        called for every sound.
  690.  
  691.  
  692. INPUTS
  693.        audioctrl - A pointer to an AHIAudioCtrl structure obtained from
  694.            AHI_AllocAudioA(). If NULL, this function does nothing.
  695.  
  696.  
  697. EXAMPLE
  698.  
  699.  
  700. NOTES
  701.  
  702.  
  703. BUGS
  704.  
  705.  
  706. SEE ALSO
  707.        AHI_AllocAudioA(), AHI_UnloadSound()
  708.  
  709.  
  710. ahi.device/AHI_FreeAudioRequest
  711.  
  712. NAME
  713.        AHI_FreeAudioRequest -- frees requester resources 
  714.  
  715.  
  716. SYNOPSIS
  717.        AHI_FreeAudioRequest( requester );
  718.                              A0
  719.  
  720.        void AHI_FreeAudioRequest( struct AHIAudioModeRequester * );
  721.  
  722.  
  723. FUNCTION
  724.        Frees any resources allocated by AHI_AllocAudioRequestA(). Once a
  725.        requester has been freed, it can no longer be used with other calls to
  726.        AHI_AudioRequestA().
  727.  
  728.  
  729. INPUTS
  730.        requester - Requester obtained from AHI_AllocAudioRequestA(), or NULL
  731.        in which case this function does nothing.
  732.  
  733.  
  734. RESULT
  735.  
  736.  
  737. EXAMPLE
  738.  
  739.  
  740. NOTES
  741.  
  742.  
  743. BUGS
  744.  
  745.  
  746. SEE ALSO
  747.       AHI_AllocAudioRequestA()
  748.  
  749.  
  750. ahi.device/AHI_GetAudioAttrsA
  751.  
  752. NAME
  753.        AHI_GetAudioAttrsA -- examine an audio mode via a tag list
  754.        AHI_GetAudioAttrs -- varargs stub for AHI_GetAudioAttrsA()
  755.  
  756.  
  757. SYNOPSIS
  758.        success = AHI_GetAudioAttrsA( ID, [audioctrl], tags );
  759.        D0                            D0  A2           A1
  760.  
  761.        BOOL AHI_GetAudioAttrsA( ULONG, struct AHIAudioCtrl *,
  762.                                 struct TagItem * );
  763.  
  764.        success = AHI_GetAudioAttrs( ID, [audioctrl], attr1, &result1, ...);
  765.  
  766.        BOOL AHI_GetAudioAttrs( ULONG, struct AHIAudioCtrl *, Tag, ... );
  767.  
  768.  
  769. FUNCTION
  770.        Retrieve information about an audio mode specified by ID or audioctrl
  771.        according to the tags in the tag list. For each entry in the tag
  772.        list, ti_Tag identifies the attribute, and ti_Data is mostly a
  773.        pointer to a LONG (4 bytes) variable where you wish the result to be
  774.        stored.
  775.  
  776.  
  777. INPUTS
  778.        ID - An audio mode identifier, AHI_DEFAULT_ID (V4) or AHI_INVALID_ID.
  779.        audioctrl - A pointer to an AHIAudioCtrl structure, only used if
  780.            ID equals AHI_INVALID_ID. Set to NULL if not used. If set to
  781.            NULL when used, this function returns immediately. Always set
  782.            ID to AHI_INVALID_ID and use audioctrl if you have allocated
  783.            a valid AHIAudioCtrl structure. Some of the tags return incorrect
  784.            values otherwise.
  785.        tags - A pointer to a tag list.
  786.  
  787.  
  788. TAGS
  789.        AHIDB_Volume (ULONG *) - TRUE if this mode supports volume changes.
  790.  
  791.        AHIDB_Stereo (ULONG *) - TRUE if output is in stereo. Unless
  792.            AHIDB_Panning (see below) is TRUE, all even channels are played
  793.            to the left and all odd to the right.
  794.  
  795.        AHIDB_Panning (ULONG *) - TRUE if this mode supports stereo panning.
  796.  
  797.        AHIDB_HiFi (ULONG *) - TRUE if no shortcuts, like pre-division, is
  798.            used by the mixing routines.
  799.  
  800.        AHIDB_PingPong (ULONG *) - TRUE if this mode can play samples backwards.
  801.  
  802.        AHIDB_Record (ULONG *) - TRUE if this mode can record samples.
  803.  
  804.        AHIDB_FullDuplex (ULONG *) - TRUE if this mode can record and play at
  805.            the same time.
  806.  
  807.        AHIDB_Realtime (ULONG *) - Modes which return TRUE for this fulfills
  808.            two criteria:
  809.            1) Calls to AHI_SetVol(), AHI_SetFreq() or AHI_SetSound() will be
  810.               performed within (about) 10 ms if called from a PlayFunc Hook.
  811.            2) The PlayFunc Hook will be called at the specified frequency.
  812.            If you don't use AHI's PlayFunc Hook, you must not use modes that
  813.            are not realtime. (Criterium 2 is not that obvious if you consider
  814.            a mode that renders the output to disk as a sample.)
  815.  
  816.        AHIDB_Bits (ULONG *) - The number of output bits (8, 12, 14, 16 etc).
  817.  
  818.        AHIDB_MaxChannels (ULONG *) - The maximum number of channels this mode
  819.            can handle.
  820.  
  821.        AHIDB_MinMixFreq (ULONG *) - The minimum mixing frequency supported.
  822.  
  823.        AHIDB_MaxMixFreq (ULONG *) - The maximum mixing frequency supported.
  824.  
  825.        AHIDB_Frequencies (ULONG *) - The number of different sample rates
  826.            available.
  827.  
  828.        AHIDB_FrequencyArg (ULONG) - Specifies which frequency
  829.            AHIDB_Frequency should return (see below). Range is 0 to
  830.            AHIDB_Frequencies-1 (including).
  831.            NOTE: ti_Data is NOT a pointer, but an ULONG.
  832.  
  833.        AHIDB_Frequency (ULONG *) - Return the frequency associated with the
  834.            index number specified with AHIDB_FrequencyArg (see above).
  835.  
  836.        AHIDB_IndexArg (ULONG) - AHIDB_Index will return the index which
  837.            gives the closest frequency to AHIDB_IndexArg
  838.            NOTE: ti_Data is NOT a pointer, but an ULONG.
  839.  
  840.        AHIDB_Index (ULONG *) - Return the index associated with the frequency
  841.            specified with AHIDB_IndexArg (see above).
  842.  
  843.        AHIDB_MaxPlaySamples (ULONG *) - Return the lowest number of sample
  844.            frames that must be present in memory when AHIST_DYNAMICSAMPLE
  845.            sounds are used. This number must then be scaled by Fs/Fm, where
  846.            Fs is the frequency of the sound and Fm is the mixing frequency.
  847.  
  848.        AHIDB_MaxRecordSamples (ULONG *) - Return the number of sample frames
  849.            you will receive each time the RecordFunc is called.
  850.  
  851.        AHIDB_BufferLen (ULONG) - Specifies how many characters will be
  852.            copied when requesting text attributes. Default is 0, which
  853.            means that AHIDB_Driver, AHIDB_Name, AHIDB_Author,
  854.            AHIDB_Copyright, AHIDB_Version and AHIDB_Annotation,
  855.            AHIDB_Input and AHIDB_Output will do nothing.
  856.  
  857.        AHIDB_Driver (STRPTR) - Name of driver (excluding path and
  858.            extension). 
  859.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  860.            will be stored. See AHIDB_BufferLen.
  861.  
  862.        AHIDB_Name (STRPTR) - Human readable name of this mode.
  863.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  864.            will be stored. See AHIDB_BufferLen.
  865.  
  866.        AHIDB_Author (STRPTR) - Name of driver author.
  867.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  868.            will be stored. See AHIDB_BufferLen.
  869.  
  870.        AHIDB_Copyright (STRPTR) - Driver copyright notice.
  871.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  872.            will be stored. See AHIDB_BufferLen
  873.  
  874.        AHIDB_Version (STRPTR) - Driver version string.
  875.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  876.            will be stored. See AHIDB_BufferLen.
  877.  
  878.        AHIDB_Annotation (STRPTR) - Annotation by driver author.
  879.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  880.            will be stored. See AHIDB_BufferLen.
  881.  
  882.        AHIDB_MinMonitorVolume (Fixed *)
  883.        AHIDB_MaxMonitorVolume (Fixed *) - Lower/upper limit for input
  884.            monitor volume, see AHI_ControlAudioA(). If both are 0.0,
  885.            the sound hardware does not have an input monitor feature.
  886.            If both are same, but not 0.0, the hardware always sends the
  887.            recorded sound to the outputs (at the given volume). (V2)
  888.  
  889.        AHIDB_MinInputGain (Fixed *)
  890.        AHIDB_MaxInputGain (Fixed *) - Lower/upper limit for input gain,
  891.            see AHI_ControlAudioA(). If both are same, there is no input
  892.            gain hardware. (V2)
  893.  
  894.        AHIDB_MinOutputVolume (Fixed *)
  895.        AHIDB_MaxOutputVolume (Fixed *) - Lower/upper limit for output
  896.            volume, see AHI_ControlAudioA(). If both are same, the sound
  897.            card does not have volume control. (V2)
  898.  
  899.        AHIDB_Inputs (ULONG *) - The number of inputs the sound card has.
  900.            (V2)
  901.  
  902.        AHIDB_InputArg (ULONG) - Specifies what AHIDB_Input should return
  903.            (see below). Range is 0 to AHIDB_Inputs-1 (including).
  904.            NOTE: ti_Data is NOT a pointer, but an ULONG. (V2)
  905.  
  906.        AHIDB_Input (STRPTR) - Gives a human readable string describing the
  907.            input associated with the index specified with AHIDB_InputArg
  908.            (see above). See AHI_ControlAudioA() for how to select one.
  909.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  910.            will be stored. See AHIDB_BufferLen. (V2)
  911.  
  912.        AHIDB_Outputs (ULONG *) - The number of outputs the sound card
  913.            has. (V2)
  914.  
  915.        AHIDB_OutputArg (ULONG) - Specifies what AHIDB_Output should return
  916.            (see below). Range is 0 to AHIDB_Outputs-1 (including)
  917.            NOTE: ti_Data is NOT a pointer, but an ULONG. (V2)
  918.  
  919.        AHIDB_Output (STRPTR) - Gives a human readable string describing the
  920.            output associated with the index specified with AHIDB_OutputArg
  921.            (see above). See AHI_ControlAudioA() for how to select one.
  922.            NOTE: ti_Data is a pointer to an UBYTE array where the name
  923.            will be stored. See AHIDB_BufferLen. (V2)
  924.  
  925.        AHIDB_AudioID (ULONG *) - The ID for this mode. (V4)
  926.  
  927.        If the requested information cannot be found, the variable will be not
  928.        be touched.
  929.  
  930.  
  931. RESULT
  932.        TRUE if everything went well.
  933.  
  934.  
  935. EXAMPLE
  936.  
  937.  
  938. NOTES
  939.  
  940.  
  941. BUGS
  942.        In versions earlier than 3, the tags that filled a string buffer would
  943.        not NULL-terminate the string on buffer overflows.
  944.  
  945.  
  946. SEE ALSO
  947.       AHI_NextAudioID(), AHI_BestAudioIDA()
  948.  
  949.  
  950. ahi.device/AHI_LoadSound
  951.  
  952. NAME
  953.        AHI_LoadSound -- prepare a sound for playback
  954.  
  955.  
  956. SYNOPSIS
  957.        error = AHI_LoadSound( sound, type, info, audioctrl );
  958.        D0                     D0:16  D1    A0    A2
  959.  
  960.        ULONG AHI_LoadSound( UWORD, ULONG, APTR, struct AHIAudioCtrl * );
  961.  
  962.  
  963. FUNCTION
  964.        Defines an ID number for the sound and prepares it for playback.
  965.  
  966.  
  967. INPUTS
  968.        sound - The numeric ID to be used as a reference to this sound.
  969.            The ID is a number greater or equal to 0 and less than what you
  970.            specified with AHIA_Sounds when you called AHI_AllocAudioA().
  971.        type - The type of the sound. Currently four types are supported:
  972.            AHIST_SAMPLE - array of 8 or 16 bit samples. Note that the
  973.                portion of memory where the sample is stored must NOT be
  974.                altered until AHI_UnloadSound() has been called! This is
  975.                because some audio drivers may wish to upload the samples
  976.                to local RAM. It is OK to read, though.
  977.  
  978.            AHIST_DYNAMICSAMPLE - array of 8 or 16 bit samples, which can be
  979.                updated dynamically. Typically used to play data that is
  980.                loaded from disk or calculated realtime.
  981.                Avoid using this sound type as much as possible; it will
  982.                use much more CPU power than AHIST_SAMPLE on a DMA/DSP
  983.                sound card.
  984.  
  985.            AHIST_INPUT - The input from your sampler (not fully functional
  986.                yet).
  987.  
  988.        info - Depends on type:
  989.            AHIST_SAMPLE - A pointer to a struct AHISampleInfo, filled with:
  990.                ahisi_Type - Format of samples (only two supported).
  991.                    AHIST_M8S: Mono, 8 bit signed (BYTEs).
  992.                    AHIST_S8S: Stereo, 8 bit signed (2×BYTEs) (V4). 
  993.                    AHIST_M16S: Mono, 16 bit signed (WORDs).
  994.                    AHIST_S16S: Stereo, 16 bit signed (2×WORDs) (V4).
  995.                ahisi_Address - Address to the sample array.
  996.                ahisi_Length - The size of the array, in samples.
  997.                Don't even think of setting ahisi_Address to 0 and
  998.                ahisi_Length to 0xffffffff as you can do with
  999.                AHIST_DYNAMICSAMPLE! Very few DMA/DSP cards has 4 GB onboard
  1000.                RAM...
  1001.  
  1002.            AHIST_DYNAMICSAMPLE A pointer to a struct AHISampleInfo, filled
  1003.                as described above (AHIST_SAMPLE).
  1004.                If ahisi_Address is 0 and ahisi_Length is 0xffffffff
  1005.                AHI_SetSound() can take the real address of an 8 bit sample
  1006.                to be played as offset argument. Unfortunately, this does not
  1007.                work for 16 bit samples.
  1008.  
  1009.            AHIST_INPUT - Always set info to NULL.
  1010.                Note that AHI_SetFreq() may only be called with AHI_MIXFREQ
  1011.                for this sample type.
  1012.  
  1013.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1014.  
  1015.  
  1016. RESULT
  1017.        An error code, defined in <devices/ahi.h>.
  1018.  
  1019.  
  1020. EXAMPLE
  1021.  
  1022.  
  1023. NOTES
  1024.        There is no need to place a sample array in Chip memory, but it
  1025.        MUST NOT be swapped out! Allocate your sample memory with the
  1026.        MEMF_PUBLIC flag set. 
  1027.  
  1028.        SoundFunc will be called in the same manner as Paula interrupts
  1029.        occur; when the device has updated its internal variables and can
  1030.        accept new commands.
  1031.  
  1032.  
  1033. BUGS
  1034.        AHIST_INPUT does not fully work yet.
  1035.  
  1036.  
  1037. SEE ALSO
  1038.        AHI_UnloadSound(), AHI_SetEffect(), AHI_SetFreq(), AHI_SetSound(),
  1039.        AHI_SetVol(), <devices/ahi.h>
  1040.  
  1041.  
  1042. ahi.device/AHI_NextAudioID
  1043.  
  1044. NAME
  1045.        AHI_NextAudioID -- iterate current audio mode identifiers
  1046.  
  1047.  
  1048. SYNOPSIS
  1049.        next_ID = AHI_NextAudioID( last_ID );
  1050.        D0                         D0
  1051.  
  1052.        ULONG AHI_NextAudioID( ULONG );
  1053.  
  1054.  
  1055. FUNCTION
  1056.        This function is used to iterate through all current AudioIDs in
  1057.        the audio database.
  1058.  
  1059.  
  1060. INPUTS
  1061.        last_ID - previous AudioID or AHI_INVALID_ID if beginning iteration.
  1062.  
  1063.  
  1064. RESULT
  1065.        next_ID - subsequent AudioID or AHI_INVALID_ID if no more IDs.
  1066.  
  1067.  
  1068. EXAMPLE
  1069.  
  1070.  
  1071. NOTES
  1072.  
  1073.  
  1074. BUGS
  1075.  
  1076.  
  1077. SEE ALSO
  1078.       AHI_GetAudioAttrsA(), AHI_BestAudioIDA()
  1079.  
  1080.  
  1081. ahi.device/AHI_PlayA
  1082.  
  1083. NAME
  1084.        AHI_PlayA -- Start multiple sounds in one call (V4)
  1085.        AHI_Play -- varargs stub for AHI_PlayA()
  1086.  
  1087.  
  1088. SYNOPSIS
  1089.        AHI_PlayA( audioctrl, tags );
  1090.                   A2         A1
  1091.  
  1092.        void AHI_PlayA( struct AHIAudioCtrl *, struct TagItem * );
  1093.  
  1094.        AHI_Play( AudioCtrl, tag1, ...);
  1095.  
  1096.        void AHI_Play( struct AHIAudioCtrl *, Tag, ... );
  1097.  
  1098.  
  1099. FUNCTION
  1100.        This function performs the same actions as multiple calls to
  1101.        AHI_SetFreq(), AHI_SetSound() and AHI_SetVol(). The advantages
  1102.        of using only one call is that simple loops can be set without
  1103.        using a SoundFunc (see AHI_AllocAudioA(), tag AHIA_SoundFunc) and
  1104.        that sounds on different channels can be synchronized even when the
  1105.        sounds are not started from a PlayerFunc (see AHI_AllocAudioA(), tag
  1106.        AHIA_PlayerFunc). The disadvantage is that this call has more
  1107.        overhead than AHI_SetFreq(), AHI_SetSound() and AHI_SetVol(). It is
  1108.        therefore recommended that you only use this call if you are not
  1109.        calling from a SoundFunc or PlayerFunc.
  1110.  
  1111.        The supplied tag list works like a 'program'. This means that
  1112.        the order of tags matter.
  1113.  
  1114.  
  1115. INPUTS
  1116.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1117.        tags - A pointer to a tag list.
  1118.  
  1119.  
  1120. TAGS
  1121.        AHIP_BeginChannel (UWORD) - Before you start setting attributes
  1122.            for a sound to play, you have to use this tag to chose a
  1123.            channel to operate on. If AHIP_BeginChannel is omitted, the
  1124.            result is undefined.
  1125.  
  1126.        AHIP_EndChannel (ULONG) - Signals the end of attributes for
  1127.            the current channel. If AHIP_EndChannel is omitted, the result
  1128.            is undefined. ti_Data MUST BE NULL!
  1129.  
  1130.        AHIP_Freq (ULONG) - The playback frequency in Hertz or AHI_MIXFREQ.
  1131.  
  1132.        AHIP_Vol (Fixed) - The desired volume. If omitted, but AHIP_Pan is
  1133.            present, AHIP_Vol defaults to 0.
  1134.  
  1135.        AHIP_Pan (sposition) - The desired panning. If omitted, but AHIP_Vol
  1136.            is present, AHIP_Pan defaults to 0 (extreme left).
  1137.  
  1138.        AHIP_Sound (UWORD) - Sound to be played, or AHI_NOSOUND.
  1139.  
  1140.        AHIP_Offset (ULONG) - Specifies an offset (in samples) into the
  1141.            sound. If this tag is present, AHIP_Length MUST be present too!
  1142.  
  1143.        AHIP_Length (LONG) - Specifies how many samples that should be
  1144.            player.
  1145.  
  1146.        AHIP_LoopFreq (ULONG)
  1147.        AHIP_LoopVol (Fixed)
  1148.        AHIP_LoopPan (sposition)
  1149.        AHIP_LoopSound (UWORD)
  1150.        AHIP_LoopOffset (ULONG)
  1151.        AHIP_LoopLength (LONG) - These tags can be used to set simple loop
  1152.           attributes. They default to their sisters. These tags must be
  1153.           after the other tags.
  1154.  
  1155.  
  1156. RESULT
  1157.  
  1158.  
  1159. EXAMPLE
  1160.  
  1161.  
  1162. NOTES
  1163.  
  1164.  
  1165. BUGS
  1166.  
  1167.  
  1168. SEE ALSO
  1169.        AHI_SetFreq(), AHI_SetSound(), AHI_SetVol()
  1170.  
  1171.  
  1172. ahi.device/AHI_SampleFrameSize
  1173.  
  1174. NAME
  1175.        AHI_SampleFrameSize -- get the size of a sample frame (V4)
  1176.  
  1177.  
  1178. SYNOPSIS
  1179.        size = AHI_SampleFrameSize( sampletype );
  1180.        D0                          D0
  1181.  
  1182.        ULONG AHI_SampleFrameSize( ULONG );
  1183.  
  1184.  
  1185. FUNCTION
  1186.        Returns the size in bytes of a sample frame for a given sample type.
  1187.  
  1188.  
  1189. INPUTS
  1190.        sampletype - The sample type to examine. See <devices/ahi.h> for
  1191.            possible types.
  1192.  
  1193.  
  1194. RESULT
  1195.  
  1196.  
  1197. EXAMPLE
  1198.  
  1199.  
  1200. NOTES
  1201.  
  1202.  
  1203. BUGS
  1204.  
  1205.  
  1206. SEE ALSO
  1207.       <devices/ahi.h>
  1208.  
  1209.  
  1210. ahi.device/AHI_SetEffect
  1211.  
  1212. NAME
  1213.        AHI_SetEffect -- set effect
  1214.  
  1215.  
  1216. SYNOPSIS
  1217.        error = AHI_SetEffect( effect, audioctrl );
  1218.        d0                     A0      A2
  1219.  
  1220.        ULONG AHI_SetEffect( APTR, struct AHIAudioCtrl * );
  1221.  
  1222.  
  1223. FUNCTION
  1224.        Selects an effect to be used, described by a structure.
  1225.  
  1226.  
  1227. INPUTS
  1228.        effect - A pointer to an effect data structure, as defined in
  1229.            <devices/ahi.h>. The following effects are defined:
  1230.            AHIET_MASTERVOLUME - Changes the volume for all channels. Can
  1231.                also be used to boost volume over 100%.
  1232.            AHIET_OUTPUTBUFFER - Gives READ-ONLY access to the mixed output.
  1233.                Can be used to show nice scopes and VU-meters.
  1234.            AHIET_DSPMASK - Select which channels will be affected by the
  1235.                DSP effects. (V4)
  1236.            AHIET_DSPECHO - A DSP effects that adds (cross-)echo and delay.
  1237.                (V4)
  1238.            AHIET_CHANNELINFO - Get info about all channels. (V4)
  1239.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1240.  
  1241.  
  1242. EFFECTS
  1243.        AHIET_MASTERVOLUME - Effect is a struct AHIEffMasterVolume, with
  1244.            ahiemv_Volume set to the desired volume. The range is 0 to
  1245.            (channels/hardware channel). Assume you have 4 channels in
  1246.            mono mode. The range is then 0.0 to 4.0. The range is the same
  1247.            if the mode is stereo with panning. However, assume you have 4
  1248.            channels with a stereo mode *without* panning. Then you have two
  1249.            channels to the left and two to the right => range is 0.0 - 2.0.
  1250.            Setting the volume outside the range will give an unpredictable
  1251.            result!
  1252.  
  1253.        AHIET_OUTPUTBUFFER - Effect is a struct AHIEffOutputBuffer, with
  1254.            ahieob_Func pointing to a hook that will be called with the
  1255.            following parameters:
  1256.                A0 - (struct Hook *)
  1257.                A2 - (struct AHIAudioCtrl *)
  1258.                A1 - (struct AHIEffOutputBuffer *)
  1259.            The information you are looking for then is in ahieob_Type,
  1260.            ahieob_Buffer and ahieob_Length. Always check ahieob_Type!
  1261.            ahieob_Length is neither in bytes nor samples, but sample frames.
  1262.  
  1263.        AHIET_DSPMASK - Effect is a struct AHIEffDSPMask, where ahiedm_Mask
  1264.            is an array with ahiedm_Channels elements. Each UBYTE in the
  1265.            array can either make the channel 'wet' (affected by the DSP
  1266.            effects), by using the AHIEDM_WET constant or 'dry' (not
  1267.            affected by the DSP effects) by using the AHIEDM_DRY constant.
  1268.            The default is all channels wet. If ahiedm_Channels does not
  1269.            equal the current number of channels allocated, the result of
  1270.            this call is undefined (crash warning!). (V4)
  1271.  
  1272.        AHIET_DSPECHO - Effect is a struct AHIEffDSPEcho.
  1273.            ahiede_Delay is the delay in samples (and thus depends on the
  1274.            mixing rate).
  1275.  
  1276.            ahiede_Feedback is a Fixed value between 0 and 1.0, and defines
  1277.            how much of the delayed signal should be feed back to the delay
  1278.            stage. Setting this to 0 gives a delay effect, otherwise echo.
  1279.  
  1280.            ahiede_Mix tells how much of the delayed signal should be mixed
  1281.            with the normal signal. Setting this to 0 disables delay/echo,
  1282.            and setting it to 1.0 outputs only the delay/echo signal.
  1283.  
  1284.            ahiede_Cross only has effect of the current playback mode is
  1285.            stereo. It tells how the delayed signal should be panned to
  1286.            the other channel. 0 means no cross echo, 1.0 means full
  1287.            cross echo.
  1288.  
  1289.            If the user has enabled "Fast Echo", AHI may take several short-
  1290.            cuts to increase the performance. This could include rounding the
  1291.            parameters to a power of two, or even to the extremes. 
  1292.  
  1293.            If you set ahiede_Mix to 0x10000 and ahiede_Cross to 0x0, much
  1294.            faster mixing routines will be used, and "Fast Echo" will improve
  1295.            that even more.
  1296.  
  1297.            Otherwise, even with "Fast Echo" turned on, this effect will 
  1298.            probably suck some major CPU cycles on most sound hardware. (V4)
  1299.  
  1300.        AHIET_CHANNELINFO - Effect is a struct AHIEffChannelInfo, where
  1301.            ahieci_Func is pointing to a hook that will be called with the
  1302.            following parameters:
  1303.                A0 - (struct Hook *)
  1304.                A2 - (struct AHIAudioCtrl *)
  1305.                A1 - (struct AHIEffChannelInfo *)
  1306.            ahieci_Channels must equal the current number of channels used.
  1307.            ahieci_Offset is an array of ULONGs, which will be filled by
  1308.            AHI before the hook is called (the offset is specified in sample
  1309.            frames). The array must have at least ahieci_Channels elements.
  1310.  
  1311.            This "effect" can be used to find out how far each channel has
  1312.            played. You must probably keep track of the other parameters
  1313.            yourself (like which sound is playing, it's volume, balance and
  1314.            frequency etc) in order have meaningful usage of the information.
  1315.            (V4)
  1316.  
  1317.  
  1318.        NOTE! To turn off an effect, call again with ahie_Effect OR:ed
  1319.        with AHIET_CANCEL. For example, it is NOT correct to disable
  1320.        the AHIET_MASTERVOLUME effect by setting ahiemv_Volume to 1.0!
  1321.  
  1322.        It is important that you always turn off effects before you
  1323.        deallocate the audio hardware. Otherwise memory may be lost.
  1324.        It is safe to turn off an effect that has never been turned on
  1325.        in the first place.
  1326.  
  1327.        Never count on that an effect will be available. For example,
  1328.        AHIET_OUTPUTBUFFER is impossible to implement with some sound
  1329.        cards.
  1330.  
  1331.  
  1332. RESULT
  1333.        An error code, defined in <devices/ahi.h>.
  1334.  
  1335.  
  1336. EXAMPLE
  1337.  
  1338.  
  1339. NOTES
  1340.        Unlike the other functions whose names begin with "AHI_Set", this
  1341.        function may NOT be called from an interrupt (or AHI Hook).
  1342.  
  1343.        Previous to V4, this call always returned AHIE_OK.
  1344.  
  1345.  
  1346. BUGS
  1347.        The idea of updating the source structure instead of allocating
  1348.        a new one that is passed the hook it pretty flawed. The reason is
  1349.        that AHI_SetEffect() originally could be called from interrupts,
  1350.        and memory allocation is not allowed from within interrupts.
  1351.  
  1352.  
  1353. SEE ALSO
  1354.        AHI_SetFreq(), AHI_SetSound(), AHI_SetVol(), AHI_LoadSound(),
  1355.        <devices/ahi.h>
  1356.  
  1357.  
  1358. ahi.device/AHI_SetFreq
  1359.  
  1360. NAME
  1361.        AHI_SetFreq -- set frequency for a channel
  1362.  
  1363.  
  1364. SYNOPSIS
  1365.        AHI_SetFreq( channel, freq, audioctrl, flags );
  1366.                     D0:16    D1    A2         D2
  1367.  
  1368.        void AHI_SetFreq( UWORD, ULONG, struct AHIAudioCtrl *, ULONG );
  1369.  
  1370.  
  1371. FUNCTION
  1372.        Sets the playback frequency for a channel.
  1373.  
  1374.  
  1375. INPUTS
  1376.        channel - The channel to set playback frequency for.
  1377.        freq - The playback frequency in Hertz. Can also be AHI_MIXFREQ,
  1378.            is the current mixing frequency (only usable with AHIST_INPUT
  1379.            sounds), or 0 to temporary stop the sound (it will restart at
  1380.            the same point when its frequency changed). Setting the frequency
  1381.            of an AHIST_INPUT sound is not supported, and the result is
  1382.            undefined.
  1383.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1384.        flags - Only one flag is defined
  1385.            AHISF_IMM - Set this flag if this command should take effect
  1386.                immediately. If this bit is not set, the command will not
  1387.                take effect until the current sound is finished. MUST NOT
  1388.                be set if called from a SoundFunc. See the programming
  1389.                guidelines for more information about this flag.
  1390.  
  1391.  
  1392. RESULT
  1393.  
  1394.  
  1395. EXAMPLE
  1396.  
  1397.  
  1398. NOTES
  1399.        It is safe to call this function from an interrupt.
  1400.  
  1401.  
  1402. BUGS
  1403.  
  1404.  
  1405. SEE ALSO
  1406.        AHI_SetEffect(),  AHI_SetSound(), AHI_SetVol(), AHI_LoadSound()
  1407.  
  1408.  
  1409. ahi.device/AHI_SetSound
  1410.  
  1411. NAME
  1412.        AHI_SetSound -- set what sound to play for a channel
  1413.  
  1414.  
  1415. SYNOPSIS
  1416.        AHI_SetSound( channel, sound, offset, length, audioctrl, flags );
  1417.                       D0:16   D1:16   D2      D3      A2         D4
  1418.  
  1419.        void AHI_SetSound( UWORD, UWORD, ULONG, LONG,
  1420.                           struct AHIAudioCtrl *, ULONG );
  1421.  
  1422.  
  1423. FUNCTION
  1424.        Sets a sound to be played on a channel.
  1425.  
  1426.  
  1427. INPUTS
  1428.        channel - The channel to set sound for.
  1429.        sound - Sound to be played, or AHI_NOSOUND to turn the channel off.
  1430.        offset - Only available if the sound type is AHIST_SAMPLE or
  1431.            AHIST_DYNAMICSAMPLE. Must be 0 otherwise.
  1432.            Specifies an offset (in samples) where the playback will begin.
  1433.            If you wish to play the whole sound, set offset to 0.
  1434.        length - Only available if the sound type is AHIST_SAMPLE or
  1435.            AHIST_DYNAMICSAMPLE. Must be 0 otherwise.
  1436.            Specifies how many samples that should be played. If you
  1437.            wish to play the whole sound forwards, set offset to 0 and length
  1438.            to either 0 or the length of the sample array. You may not set
  1439.            length to 0 if offset is not 0! To play a sound backwards, just
  1440.            set length to a negative number.
  1441.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1442.        flags - Only one flag is defined
  1443.            AHISF_IMM - Set this flag if this command should take effect
  1444.                immediately. If this bit is not set, the command will not
  1445.                take effect until the current sound is finished. MUST NOT
  1446.                be set if called from a SoundFunc. See the programming
  1447.                guidelines for more information about this flag.
  1448.  
  1449.  
  1450. RESULT
  1451.  
  1452.  
  1453. EXAMPLE
  1454.  
  1455.  
  1456. NOTES
  1457.        It is safe to call this function from an interrupt.
  1458.  
  1459.        If offset or length is not zero, make sure you do not exceed the
  1460.        sample limits.
  1461.  
  1462.  
  1463. BUGS
  1464.  
  1465.  
  1466. SEE ALSO
  1467.        AHI_SetEffect(),  AHI_SetFreq(), AHI_SetVol(), AHI_LoadSound()
  1468.  
  1469.  
  1470. ahi.device/AHI_SetVol
  1471.  
  1472. NAME
  1473.        AHI_SetVol -- set volume and stereo panning for a channel
  1474.  
  1475.  
  1476. SYNOPSIS
  1477.        AHI_SetVol( channel, volume, pan, audioctrl, flags );
  1478.                    D0:16    D1      D2   A2         D3
  1479.  
  1480.        void AHI_SetVol( UWORD, Fixed, sposition, struct AHIAudioCtrl *,
  1481.                         ULONG );
  1482.  
  1483.  
  1484. FUNCTION
  1485.        Changes the volume and stereo panning for a channel.
  1486.  
  1487.  
  1488. INPUTS
  1489.        channel - The channel to set volume for.
  1490.        volume - The desired volume. Fixed is a LONG fixed-point value with
  1491.            16 bits to the left of the point and 16 to the right
  1492.            (typedef LONG Fixed; from IFF-8SVX docs).
  1493.            Maximum volume is 1.0 (0x10000L) and 0.0 (0x0L) will turn off
  1494.            this channel. Note: The sound will continue to play, but you
  1495.            wont hear it. To stop a sound completely, use AHI_SetSound().
  1496.            Starting with V4 volume can also be negative, which tells AHI
  1497.            to invert the samples before playing. Note that all drivers
  1498.            may not be able to handle negative volume. In that case the
  1499.            absolute volume will be used.
  1500.        pan - The desired panning. sposition is the same as Fixed
  1501.            (typedef Fixed sposition; from IFF-8SVX.PAN docs).
  1502.            1.0 (0x10000L) means that the sound is panned all the way to
  1503.            the right, 0.5 (0x8000L) means the sound is centered and 0.0
  1504.            (0x0L) means that the sound is panned all the way to the left.
  1505.            Try to set Pan to the 'correct' value even if you know it has no
  1506.            effect. For example, if you know you use a mono mode, set pan to
  1507.            0.5 even if it does not matter.
  1508.            Starting with V4 pan can also be negative, which tells AHI to
  1509.            use the surround speaker for this channel. Note that all drivers
  1510.            may not be able to handle negative pan. In that case the absolute
  1511.            pan will be used.
  1512.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1513.        flags - Only one flag is defined
  1514.            AHISF_IMM - Set this flag if this command should take effect
  1515.                immediately. If this bit is not set, the command will not
  1516.                take effect until the current sound is finished. MUST NOT
  1517.                be set if called from a SoundFunc. See the programming
  1518.                guidelines for more information about this flag.
  1519.  
  1520.  
  1521. RESULT
  1522.  
  1523.  
  1524. EXAMPLE
  1525.  
  1526.  
  1527. NOTES
  1528.        It is safe to call this function from an interrupt.
  1529.  
  1530.        Negative volume or negative pan may use more CPU time than positive.
  1531.  
  1532.        Using both negative volume and negative pan will play the inverted
  1533.        sound on the surround speaker.
  1534.  
  1535.  
  1536. BUGS
  1537.  
  1538.  
  1539. SEE ALSO
  1540.        AHI_SetEffect(), AHI_SetFreq(), AHI_SetSound(), AHI_LoadSound()
  1541.        
  1542.  
  1543.  
  1544. ahi.device/AHI_UnloadSound
  1545.  
  1546. NAME
  1547.        AHI_UnloadSound -- discard a sound
  1548.  
  1549.  
  1550. SYNOPSIS
  1551.        AHI_UnloadSound( sound, audioctrl );
  1552.                         D0:16  A2
  1553.  
  1554.        void AHI_UnloadSound( UWORD, struct AHIAudioCtrl * );
  1555.  
  1556.  
  1557. FUNCTION
  1558.        Tells 'ahi.device' that this sound will not be used anymore.
  1559.  
  1560.  
  1561. INPUTS
  1562.        sound - The ID of the sound to unload.
  1563.        audioctrl - A pointer to an AHIAudioCtrl structure.
  1564.  
  1565.  
  1566. RESULT
  1567.  
  1568.  
  1569. EXAMPLE
  1570.  
  1571.  
  1572. NOTES
  1573.        This call will not break a Forbid() state.
  1574.  
  1575.  
  1576. BUGS
  1577.  
  1578.  
  1579. SEE ALSO
  1580.        AHI_LoadSound()
  1581.  
  1582.  
  1583. ahi.device/CMD_FLUSH
  1584.  
  1585. NAME
  1586.        CMD_FLUSH -- Cancel all I/O requests (V4)
  1587.  
  1588.  
  1589. FUNCTION
  1590.        Aborts ALL current requests, both active and waiting, even
  1591.        other programs requests!
  1592.  
  1593.  
  1594. IO REQUEST INPUT
  1595.        io_Device       Preset by the call to OpenDevice().
  1596.        io_Unit         Preset by the call to OpenDevice().
  1597.        io_Command      CMD_FLUSH
  1598.  
  1599.  
  1600. IO REQUEST RESULT
  1601.        io_Error        0 for success, or an error code as defined in
  1602.                        <ahi/devices.h> and <exec/errors.h>.
  1603.        io_Actual       If io_Error is 0, number of requests actually
  1604.                        flushed.
  1605.  
  1606.        The other fields, except io_Device, io_Unit and io_Command, are
  1607.        trashed.
  1608.  
  1609.  
  1610. EXAMPLE
  1611.  
  1612.  
  1613. NOTES
  1614.        This command should only be used in very rare cases, like AHI
  1615.        system utilities. Never use this command in an application.
  1616.  
  1617.  
  1618. BUGS
  1619.  
  1620.  
  1621. SEE ALSO
  1622.        CMD_RESET, <ahi/devices.h>, <exec/errors.h>
  1623.  
  1624.  
  1625. ahi.device/CMD_READ
  1626.  
  1627. NAME
  1628.        CMD_READ -- Read raw samples from audio input (V4)
  1629.  
  1630.  
  1631. FUNCTION
  1632.        Reads samples from the users prefered input to memory. The sample
  1633.        format and frequency will be converted on the fly. 
  1634.  
  1635.  
  1636. IO REQUEST INPUT
  1637.        io_Device       Preset by the call to OpenDevice().
  1638.        io_Unit         Preset by the call to OpenDevice().
  1639.        io_Command      CMD_READ
  1640.        io_Data         Pointer to the buffer where the data should be put.
  1641.        io_Length       Number of bytes to read, must be a multiple of the
  1642.                        sample frame size (see ahir_Type).
  1643.        io_Offset       Set to 0 when you use for the first time or after
  1644.                        a delay.
  1645.        ahir_Type       The desired sample format, see <ahi/devices.h>.
  1646.        ahir_Frequency  The desired sample frequency in Hertz.
  1647.  
  1648.  
  1649. IO REQUEST RESULT
  1650.        io_Error        0 for success, or an error code as defined in
  1651.                        <ahi/devices.h> and <exec/errors.h>.
  1652.        io_Actual       If io_Error is 0, number of bytes actually
  1653.                        transferred.
  1654.        io_Offset       Updated to be used as input next time.
  1655.  
  1656.        The other fields, except io_Device, io_Unit and io_Command, are
  1657.        trashed.
  1658.  
  1659.  
  1660. EXAMPLE
  1661.  
  1662.  
  1663. NOTES
  1664.  
  1665.  
  1666. BUGS
  1667.  
  1668.  
  1669. SEE ALSO
  1670.        <ahi/devices.h>, <exec/errors.h>
  1671.  
  1672.  
  1673. ahi.device/CMD_RESET
  1674.  
  1675. NAME
  1676.        CMD_RESET -- Restore device to a known state (V4)
  1677.  
  1678.  
  1679. FUNCTION
  1680.        Aborts all current requests, even other programs requests
  1681.        (CMD_FLUSH), rereads the configuration file and resets the hardware
  1682.        to its initial state
  1683.        
  1684.  
  1685.  
  1686. IO REQUEST INPUT
  1687.        io_Device       Preset by the call to OpenDevice().
  1688.        io_Unit         Preset by the call to OpenDevice().
  1689.        io_Command      CMD_RESET
  1690.  
  1691.  
  1692. IO REQUEST RESULT
  1693.        io_Error        0 for success, or an error code as defined in
  1694.                        <ahi/devices.h> and <exec/errors.h>.
  1695.  
  1696.        The other fields, except io_Device, io_Unit and io_Command, are
  1697.        trashed.
  1698.  
  1699.  
  1700. EXAMPLE
  1701.  
  1702.  
  1703. NOTES
  1704.        This command should only be used in very rare cases, like AHI
  1705.        system utilities. Never use this command in an application.
  1706.  
  1707.  
  1708. BUGS
  1709.  
  1710.  
  1711. SEE ALSO
  1712.        CMD_FLUSH, <ahi/devices.h>, <exec/errors.h>
  1713.  
  1714.  
  1715. ahi.device/CMD_START
  1716.  
  1717. NAME
  1718.        CMD_START -- start device processing (like ^Q) (V4)
  1719.  
  1720.  
  1721. FUNCTION
  1722.        All CMD_WRITE's that has been sent to the device since CMD_STOP
  1723.        will be started at once, synchronized.
  1724.  
  1725.  
  1726. IO REQUEST INPUT
  1727.        io_Device       Preset by the call to OpenDevice().
  1728.        io_Unit         Preset by the call to OpenDevice().
  1729.        io_Command      CMD_START
  1730.  
  1731.  
  1732. IO REQUEST RESULT
  1733.        io_Error        0 for success, or an error code as defined in
  1734.                        <ahi/devices.h> and <exec/errors.h>.
  1735.        io_Actual       If io_Error is 0, number of requests actually
  1736.                        flushed.
  1737.  
  1738.        The other fields, except io_Device, io_Unit and io_Command, are
  1739.        trashed.
  1740.  
  1741.  
  1742. EXAMPLE
  1743.  
  1744.  
  1745. NOTES
  1746.        Unlike most (all?) other devices, CMD_STOP and CMD_START do nest in
  1747.        ahi.device.
  1748.  
  1749.  
  1750. BUGS
  1751.  
  1752.  
  1753. SEE ALSO
  1754.        CMD_STOP, <ahi/devices.h>, <exec/errors.h>
  1755.  
  1756.  
  1757. ahi.device/CMD_STOP
  1758.  
  1759. NAME
  1760.        CMD_STOP -- stop device processing (like ^S) (V4)
  1761.  
  1762.  
  1763. FUNCTION
  1764.        Stops all CMD_WRITE processing. All writes will be queued, and
  1765.        are not processed until CMD_START. This is useful for synchronizing
  1766.        two or more CMD_WRITE's.
  1767.  
  1768.  
  1769. IO REQUEST INPUT
  1770.        io_Device       Preset by the call to OpenDevice().
  1771.        io_Unit         Preset by the call to OpenDevice().
  1772.        io_Command      CMD_STOP
  1773.  
  1774.  
  1775. IO REQUEST RESULT
  1776.        io_Error        0 for success, or an error code as defined in
  1777.                        <ahi/devices.h> and <exec/errors.h>.
  1778.        io_Actual       If io_Error is 0, number of requests actually
  1779.                        flushed.
  1780.  
  1781.        The other fields, except io_Device, io_Unit and io_Command, are
  1782.        trashed.
  1783.  
  1784.  
  1785. EXAMPLE
  1786.  
  1787.  
  1788. NOTES
  1789.        This command affects ALL writes, even those sent by other
  1790.        applications. Make sure the code between CMD_STOP and CMD_START
  1791.        runs as fast as possible!
  1792.  
  1793.        Unlike most (all?) other devices, CMD_STOP and CMD_START do nest in
  1794.        ahi.device.
  1795.  
  1796.  
  1797. BUGS
  1798.  
  1799.  
  1800. SEE ALSO
  1801.        CMD_START, <ahi/devices.h>, <exec/errors.h>
  1802.  
  1803.  
  1804. ahi.device/CMD_WRITE
  1805.  
  1806. NAME
  1807.        CMD_WRITE -- Write raw samples to audio output (V4)
  1808.  
  1809.  
  1810. FUNCTION
  1811.        Plays the samples to the users prefered audio output.
  1812.  
  1813.  
  1814. IO REQUEST INPUT
  1815.        io_Device       Preset by the call to OpenDevice().
  1816.        io_Unit         Preset by the call to OpenDevice().
  1817.        io_Command      CMD_WRITE
  1818.        io_Data         Pointer to the buffer of samples to be played.
  1819.        io_Length       Number of bytes to play, must be a multiple of the
  1820.                        sample frame size (see ahir_Type).
  1821.        io_Offset       Must be 0.
  1822.        ahir_Type       The desired sample format, see <ahi/devices.h>.
  1823.        ahir_Frequency  The desired sample frequency in Hertz.
  1824.        ahir_Volume     The desired volume. The range is 0 to 0x10000, where
  1825.                        0 means muted and 0x10000 (== 1.0) means full volume.
  1826.        ahir_Position   Defines the stereo balance. 0 is far left, 0x8000 is
  1827.                        center and 0x10000 is far right.
  1828.        ahir_Link       If non-zero, pointer to a previously sent AHIRequest
  1829.                        which this AHIRequest will be linked to. This
  1830.                        request will be delayed until the old one is
  1831.                        finished (used for double buffering). Must be set
  1832.                        to NULL if not used.
  1833.  
  1834.  
  1835. IO REQUEST RESULT
  1836.        io_Error        0 for success, or an error code as defined in
  1837.                        <ahi/devices.h> and <exec/errors.h>.
  1838.        io_Actual       If io_Error is 0, number of bytes actually
  1839.                        played.
  1840.  
  1841.        The other fields, except io_Device, io_Unit and io_Command, are
  1842.        trashed.
  1843.  
  1844.  
  1845. EXAMPLE
  1846.  
  1847.  
  1848. NOTES
  1849.  
  1850.  
  1851. BUGS
  1852.        32 bit samples are not allowed yet.
  1853.  
  1854.  
  1855. SEE ALSO
  1856.        <ahi/devices.h>, <exec/errors.h>
  1857.  
  1858.  
  1859. ahi.device/CloseDevice
  1860.  
  1861. NAME
  1862.        CloseDevice -- Close the device
  1863.  
  1864.  
  1865. SYNOPSIS
  1866.        CloseDevice(ioRequest)
  1867.                    A1
  1868.  
  1869.        void CloseDevice(struct IORequest *);
  1870.  
  1871.  
  1872. FUNCTION
  1873.        This is an exec call that closes the device. Every OpenDevice()
  1874.        must be matched with a call to CloseDevice().
  1875.  
  1876.        The user must ensure that all outstanding IO Requests have been
  1877.        returned before closing the device.
  1878.  
  1879.  
  1880. INPUTS
  1881.        ioRequest - a pointer to the same struct AHIRequest that was used
  1882.            to open the device.
  1883.  
  1884.  
  1885. RESULT
  1886.  
  1887.  
  1888. EXAMPLE
  1889.  
  1890.  
  1891. NOTES
  1892.  
  1893.  
  1894. BUGS
  1895.  
  1896.  
  1897. SEE ALSO
  1898.       OpenDevice(), exec.library/CloseDevice()
  1899.  
  1900.  
  1901. ahi.device/NSCMD_DEVICEQUERY
  1902.  
  1903. NAME
  1904.        NSCMD_DEVICEQUERY -- Query the device for its capabilities (V4)
  1905.  
  1906.  
  1907. FUNCTION
  1908.        Fills an initialized NSDeviceQueryResult structure with
  1909.        information about the device.
  1910.  
  1911.  
  1912. IO REQUEST INPUT
  1913.        io_Device       Preset by the call to OpenDevice().
  1914.        io_Unit         Preset by the call to OpenDevice().
  1915.        io_Command      NSCMD_DEVICEQUERY
  1916.        io_Data         Pointer to the NSDeviceQueryResult structure,
  1917.                        initialized as follows:
  1918.                            DevQueryFormat - Set to 0
  1919.                            SizeAvailable  - Must be cleared.
  1920.                        It is probably good manners to clear all other
  1921.                        fields as well.
  1922.        io_Length       Size of the NSDeviceQueryResult structure.
  1923.  
  1924.  
  1925. IO REQUEST RESULT
  1926.        io_Error        0 for success, or an error code as defined in
  1927.                        <ahi/devices.h> and <exec/errors.h>.
  1928.        io_Actual       If io_Error is 0, the value in
  1929.                        NSDeviceQueryResult.SizeAvailable.
  1930.  
  1931.        The NSDeviceQueryResult structure now contains valid information.
  1932.  
  1933.        The other fields, except io_Device, io_Unit and io_Command, are
  1934.        trashed.
  1935.  
  1936.  
  1937. EXAMPLE
  1938.  
  1939.  
  1940. NOTES
  1941.  
  1942.  
  1943. BUGS
  1944.  
  1945.  
  1946. SEE ALSO
  1947.        <ahi/devices.h>, <exec/errors.h>
  1948.  
  1949.  
  1950. ahi.device/OpenDevice
  1951.  
  1952. NAME
  1953.        OpenDevice -- Open the device
  1954.  
  1955.  
  1956. SYNOPSIS
  1957.        error = OpenDevice(AHINAME, unit, ioRequest, flags)
  1958.        D0                 A0       D0    A1         D1
  1959.  
  1960.        BYTE OpenDevice(STRPTR, ULONG, struct AHIRequest *, ULONG);
  1961.  
  1962.  
  1963. FUNCTION
  1964.        This is an exec call.  Exec will search for the ahi.device, and
  1965.        if found, will pass this call on to the device.
  1966.  
  1967.  
  1968. INPUTS
  1969.        AHINAME - pointer to the string "ahi.device".
  1970.        unit - Either AHI_DEFAULT_UNIT (0), AHI_NO_UNIT (255) or any other
  1971.            unit the user has requested, for example with a UNIT tooltype.
  1972.            AHI_NO_UNIT should be used when you're using the low-level
  1973.            API.
  1974.        ioRequest - a pointer to a struct AHIRequest, initialized by
  1975.            exec.library/CreateIORequest(). ahir_Version *must* be preset
  1976.            to the version you need!
  1977.        flags - There is only one flag defined, AHIDF_NOMODESCAN, which
  1978.            asks ahi.device not to build the audio mode database if not
  1979.            already initialized. It should not be used by applications
  1980.            without good reasons (AddAudioModes uses this flag).
  1981.  
  1982.  
  1983. RESULT
  1984.        error - Same as io_Error.
  1985.        io_Error - If the call succeeded, io_Error will be 0, else
  1986.            an error code as defined in <exec/errors.h> and
  1987.            <devices/ahi.h>.
  1988.        io_Device - A pointer to the device base, which can be used
  1989.            to call the functions the device provides.
  1990.  
  1991.  
  1992. EXAMPLE
  1993.  
  1994.  
  1995. NOTES
  1996.  
  1997.  
  1998. BUGS
  1999.  
  2000.  
  2001. SEE ALSO
  2002.       CloseDevice(), exec.library/OpenDevice(), <exec/errors.h>,
  2003.       <devices/ahi.h>.
  2004.  
  2005.  
  2006.